package com.mooc.apigateway.service;

import com.mooc.apigateway.common.page.PageData;
import com.mooc.apigateway.common.page.PageParams;
import com.mooc.apigateway.dao.UserDao;
import com.mooc.apigateway.model.Agency;
import com.mooc.apigateway.model.ListResponse;
import com.mooc.apigateway.model.User;
import com.mooc.apigateway.model.UserMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AgencyService {
  
  @Autowired
  private UserDao userDao;



  public List<Agency> getAllAgency(){
    return userDao.getAllAgency();
  }


/*  public Agency getAgency(Integer id){
    return userDao.getAgencyById(id);
  }

  public void add(Agency agency) {
      userDao.addAgency(agency);
  }*/

  public PageData<User> getAllAgent(PageParams pageParams) {
    ListResponse<User> result =  userDao.getAgentList(pageParams);
    Long  count  =  result.getCount();
    return PageData.buildPage(result.getList(), count, pageParams.getPageSize(), pageParams.getPageNum());
  }


  public User getAgentDetail(Long id) {
    return userDao.getAgentById(id);
  }


  
  
}
